#include "stdafx.h"


#include "MiniKernel.h"



MiniKernel::MiniKernel(Ogre::Root *root)
{
		root->addFrameListener(this);
}

MiniKernel::~MiniKernel()
{
	//TODO DELETE all controllers
}


bool MiniKernel::frameRenderingQueued(const Ogre::FrameEvent &evt)
{
	//update all controllers
	float deltaTime = evt.timeSinceLastFrame;
	std::list<Controller*>::iterator i;
	for(i=m_controllers.begin(); i != m_controllers.end(); ++i) 
	{
		bool result = (*i)->update(deltaTime);
		if(!result){
			return false;
		}
	}

    return true;
}

void MiniKernel::addController(Controller *controller)
{
	m_controllers.push_back(controller);
}
void MiniKernel::removeController(Controller *controller)
{
	m_controllers.remove(controller);
	//TODO delete unused controllers? PROBABLY!
}